home *** CD-ROM | disk | FTP | other *** search
- /* Inline mail send arexx script for Aweb (w/ Voodoo Launch Option!)
-
- Version 1.2
-
- By Josef Faulkner (panther@gate.net) IRC: Josef
-
- Description:
- ¯¯¯¯¯¯¯¯¯¯¯
- This script is a mailto: plugin for Aweb. This script will be run in
- response to mailto: URLs, and will allow you to either compose a message
- inside Aweb's GUI and send it, with NO need for any SMTP mailers, or you
- can Launch Voodoo and let it handle the job.
-
- Features:
- ¯¯¯¯¯¯¯¯¯
- o Does not need an external SMTP mail program, does network stuff itself
- if you have the TCP: network device installed.
- o Can launch Voodoo instead, and this script will pass it the screenname
- and address, and fill in a default subject.
- o Runs transparently. After you install, you don't even know it's there.
- o Loads your signature into the <textarea> gadget.
- New in 1.1:
- o form action=mailto: submits now load form data into mail
- Note: forms with over about 200 bytes of data will not work,
- since AmigaDOS is limited to arguments at this size.
- Also: Some forms do not submit the first time, I'm trying to find
- out what conditions exist that causes some forms to submit and some
- not, if you have any ideas on why this is so, please mail me.
- New in 1.2:
- o More RFC compliant. Sorry I took so long to fix this.
- o Passes hostname in HELO
- o Passes email addresses inside of <>
- o Allows you to use smtppost (though it may be slower).
-
- Installation:
- ¯¯¯¯¯¯¯¯¯¯¯¯¯
- 1) Put this script in the same directory that the Aweb executable is in.
- 2) Set Aweb to the following settings:
- ----------------------------------------------
- Network 3: External Programs
- mailto:
- Command: sys:rexxc/rx
- Arguments: awebmailsend.rexx %s %s
- ----------------------------------------------
- Network 1: General
- [ X ] Allow Shell commands in Links (check on)
- ----------------------------------------------
- 3) Set your preferences for this script below:
- */
-
- /* >--[ Settings - Customize for your system ]------------------------< */
- SMTPHost = 'tequesta.gate.net' /* Name of your SMTP host */
- VooDoo = 'N:Voodoo/Voodoo' /* Voodoo's location on your drive */
- signature='DH2:net/.signature' /* Location of your .signature */
- myemailaddress='' /* Set to your email address, or leave
- blank, and it will look up your email
- address from your ENV variables */
- /* Main Script */
- options results
- if ~show('L','rexxsupport.library') then if ~addlib('rexxsupport.library',0,-30,0) then exit(20)
- parse arg addr
-
- if left(addr,1)='/' then addr=right(addr,length(addr)-1)
-
- address command 'delete T:awebmail.#?.html >NIL:'
- fname='T:AwebMail.'time(S)'.html'
- if (~exists('env:username'))|(~exists('env:hostname')) then do
- call open(4,fname,w)
- call writeln(4,'<html><head><title>Error</title></head><body>')
- call writeln(4,'<h1>Error</h1>')
- call writeln(4,'<b>You have not configured your USERNAME and HOSTNAME env variables.</b><br>')
- call writeln(4,'To do this, add the following lines to your User-Startup:<br>')
- call writeln(4,'<pre>setenv USERNAME <myuserid>')
- call writeln(4,'setenv HOSTNAME <myhostname')
- call writeln(4,'</pre>')
- call writeln(4,'For example, if your mail address is fred@kibo.org, you would set:')
- call writeln(4,'<pre>setenv USERNAME fred')
- call writeln(4,'setenv HOSTNAME kibo.org')
- call writeln(4,'</pre><hr>')
- call writeln(4,'<h2>Could not send mail. Please set these variables and re-try</h2>')
- call close(4)
- address AWEB.1 'OPEN file://localhost/'fname
- exit
- end
- if left(addr,9)~='postmail=' then do
- if index(addr,'?')>0 then parse var addr addr'?'cmds' 'screen
- else parse var addr addr' 'screen
- if open(1,fname,w) then do
- call writeln(1,'<html><head><title>')
- call writeln(1,addr)
- call writeln(1,'</title></head><body><h1>Mail to ')
- call writeln(1,addr'</h1>')
- call writeln(1,'<hr><form action="x-aweb:command/'voodoo' mail to 'addr' pubscreen 'screen'">')
- call writeln(1,'<input type="submit" value="Use VooDoo!"></form>')
- call writeln(1,'<form action="x-aweb:rexx/awebmailsend.rexx">')
- call writeln(1,'<input type=hidden name=postmail value=true>')
- call writeln(1,'or <input type=checkbox name=smtppost value="TRUE"> Click to Use SMTPpost instead of direct connection.')
- call writeln(1,'<hr><tt>Mail to: <input size=60 name="touser" value="'addr'"><br>')
- call writeln(1,'Subject: <input size=75 name="subj" value="mailto:'addr'"><br>')
- call writeln(1,'Mail text:</tt><hr>')
- if exists(signature) then do
- call writeln(1,'<textarea name="otext" cols=75 rows=20>')
- if index(cmds,'=')>0 then do
- call writeln(1,'Form data submitted from "mailto:" action:')
- do until cmds=''
- parse var cmds name'='value'&'cmds
- if left(cmds,1)='&' then cmds=right(cmds,length(cmds)-1)
- value=translate(value,' ','+')
- pos=index(value,'%')
- do until pos=0
- pos=index(value,'%')
- if pos>0 then do
- data=substr(value,pos,3)
- value=replace(value,data,x2c(right(data,2)))
- end
- end
- call writeln(1,' 'left(name,10,' ')'= 'value)
- end
- call writeln(1,'')
- end
- else do
- do n=1 to 4
- call writeln(1,'')
- end
- end
- call writeln(1,'--')
- call open(2,signature,r)
- do until eof(2)
- call writeln(1,readln(2))
- end
- call close(2)
- call writeln(1,'</textarea>')
- end
- else do
- call writeln(1,'<textarea name="data" cols=75 rows=20></textarea>')
- end
- call writeln(1,'<hr><input type="submit" value="Send Mail"></form>')
- call writeln(1,'</body></html>')
- call close(1)
- address AWEB.1 'OPEN file://localhost/'fname
- end
- else address command 'RequestChoice "MailToRexx" "Error" "Ok" >NIL:'
- end
- else do
- if open(1,fname,w) then do
- call open(99,'t:test',w)
- call writeln(99,addr)
- call close(99)
- do until addr=''
- parse var addr name'="'value'"'addr
- if left(addr,1)='&' then addr=right(addr,length(addr)-1)
- interpret name'=value'
- end
- otext=left(otext,length(otext)-1)
- otext=replace(otext,'*"','"')
- otext=replace(otext,'*N',d2c(10))
-
- if myemailaddress='' then do
- call open(7,'env:username',r)
- fromid=readln(7)
- call close(7)
- call open(7,'env:hostname',r)
- fromhost=readln(7)
- call close(7)
- from=fromid'@'fromhost
- end
- else from=myemailaddress
-
- data=replace(data,'.'d2c(13),'. 'd2c(13))
- if exists('T:SentMail.txt') then call open(10,'T:SentMail.txt',a)
- else call open(10,'T:SentMail.txt',w)
- call writeln(10,'From: <'from'>')
- call writeln(10,'To: 'touser)
- call writeln(10,'Subject 'subj)
- call writeln(10,'')
- call writeln(10,otext)
- call close(10)
-
- if(smtppost=TRUE) then do
- address command 'run >NIL: smtppost <t:sentmail.txt'
- end
- else do
- if ~showlist(H,'TCP') then address command 'mount TCP: from amitcp:devs/inet-mountlist'
- if ~showlist(H,'TCP') then address command 'mount TCP:'
- if showlist(H,'TCP') then do
- call open(8,'tcp:'smtphost'/25',w)
- call writeln(8,'HELO 'fromhost)
- call writeln(8,'MAIL FROM: <'from'>')
- call writeln(8,'RCPT TO: <'touser'>')
- call writeln(8,'DATA')
- call writeln(8,'From: <'from'>')
- call writeln(8,'To: 'touser)
- call writeln(8,'Subject: 'subj)
- call writeln(8,'')
- call writeln(8,otext)
- call writeln(8,'.')
- call writeln(8,'QUIT')
- call close(8)
- end
- else do
- address command 'Requestchoice title="SMTPSend" BODY="Mail NOT sent. *nCouldn''t mount TCP:" GADGETS="Ok" >NIL:'
- exit
- end
- end
-
- otext=replace(otext,'<','<')
- otext=replace(otext,'>','>')
- call writeln(1,'<html><head><title>Mail to 'touser'</title></head><body>')
- call writeln(1,'<h1>Mail sent to 'touser':</h1>')
- call writeln(1,'<h2>'subj'</h2><pre>'otext)
- call writeln(1,'</pre></body></html>')
- call close(1)
- address AWEB.1 'OPEN file://localhost/'fname
- end
- else address command 'Requestchoice title="SMTPSend" BODY="Mail Sent." GADGETS="Ok" >NIL:'
- end
- exit
-
- REPLACE: procedure
- parse arg a,b,c
- d=index(a,b)
- do while d~=0
- a=insert(c,delstr(a,d,length(b)),d-1)
- d=index(a,b)
- end
- return a
-